﻿@namespace Masa.Blazor
@inherits ThemeComponentBase

<div id="@Id"
     class="@GetClass()"
     style="@GetStyle()"
     @ref="@Ref"
     @attributes="@Attributes">
    @{
        var image = !string.IsNullOrWhiteSpace(Image);
        var icon = !string.IsNullOrWhiteSpace(Icon);
    }
    @if (Media || image || icon)
    {
        <div class="@_block.Element("media")">
            @if (Media)
            {
                <MDefaultsProvider Defaults="@_mediaDefaults">
                    @MediaContent
                </MDefaultsProvider>
            }
            else if (image)
            {
                <MImage Src="@Image" Height="@ComputedSize" Contain/>
            }
            else
            {
                <MIcon Icon="@Icon" Color="@Color" Size="@ComputedSize"/>
            }
        </div>
    }

    @RenderFragments.RenderFragmentOrText(HeadlineContent, Headline, _block.Element("headline").Name)

    @RenderFragments.RenderFragmentOrText(TitleContent, Title, _block.Element("title").Name)

    @RenderFragments.RenderFragmentOrText(TextContent, Text, css: _block.Element("text").Name, style: CssStyleUtils.GetWidth(TextWidth, "max-width"))

    @RenderFragments.RenderIfNotNull(ChildContent, css: _block.Element("content").Name)

    @if (HasActions)
    {
        <div class="@_block.Element("actions")">
            <MDefaultsProvider Defaults="@_actionsDefaults">
                @if (ActionsContent is not null)
                {
                    @ActionsContent.Invoke(_actionContext)
                }
                else
                {
                    <MButton OnClick="@HandleOnActionClick">@ActionText</MButton>
                }
            </MDefaultsProvider>
        </div>
    }
</div>